package com.doit.demo01;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class ser_cli_TCP {
    public static void main(String[] args) throws IOException {
        System.out.println("服务器正在发送数据");
        ServerSocket serverSocket = new ServerSocket(8080);
        Socket server = serverSocket.accept();
        InputStream is = server.getInputStream();
        byte[] bytes = new byte[1024];
        int len = is.read(bytes);
        System.out.println(new String(bytes,0,len));

        OutputStream os = server.getOutputStream();
        os.write("ojbk,收到".getBytes());

        os.close();
        is.close();
        server.close();
    }
}
